package br.com.simulador.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;


@Entity
@Table(name="tbl_questao")
public class Questao extends BaseEntity implements Serializable {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@Lob
	private byte[] descricao;
	
	@ManyToMany(cascade={CascadeType.DETACH})
	@JoinTable(name = "tbl_tag_questao", 
		joinColumns = @JoinColumn(name = "qst_id", referencedColumnName = "id"), 
		inverseJoinColumns = @JoinColumn(name = "tag_id", referencedColumnName = "id")
	)
	private List<Tag> tags = new ArrayList<Tag>();
	
	@ManyToOne
	private Simulado simulado;
	
	@OneToMany(mappedBy="questao", cascade={CascadeType.ALL})
	private List<ItemQuestao> listQuestoes=new ArrayList<ItemQuestao>();
	
	@Override
	public Long getId() {
		// TODO Auto-generated method stub
		return id;
	}

	public byte[] getDescricao() {
		return descricao;
	}

	public void setDescricao(byte[] descricao) {
		this.descricao = descricao;
	}

	public List<Tag> getTags() {
		return tags;
	}

	public List<ItemQuestao> getListItemQuestoes() {
		return listQuestoes;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Simulado getSimulado() {
		return simulado;
	}

	public void setSimulado(Simulado simulado) {
		this.simulado = simulado;
	}

}
